package com.dao;

import com.entity.ClassGrade;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.Map;

@Repository("classGradeDao")
public interface ClassGradeDao {
    @MapKey(value = "g_name")
    @Select("select * from class_grade")
    Map<String, Map<String, String>> queryAll();

    @Select("select * from class_grade where m_id=#{mid}")
    @Results({
            @Result(column = "gid", property = "id"),
            @Result(column = "g_name", property = "cName"),
            @Result(column = "m_id", property = "mId")
    })
    ClassGrade queryByMid(Long mid);


    @Select("select * from class_grade where gid=#{gid}")
    @Results({
            @Result(column = "gid", property = "id", id = true),
            @Result(column = "g_name", property = "cName"),
            @Result(column = "m_id", property = "mId")
    })
    ClassGrade queryById(Long gid);
}
